<!--tvm票款差异协查-->
<template>
  <div class="zhanNeiRYDLCK approve el-card is-always-shadow el-card__body">
    <el-dialog
      title="申诉"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-form v-if="isReload" class="shouPiaoYuanCYQRTZForm" :option="option" v-model="formData" @submit="handleSubmit">

        <template slot-scope="scope" slot="differenceAmount">
          <span>{{fenExYuangettoFixed(scope,'value')}}</span>
        </template>
        <!-- <template slot-scope="scope" slot="fujian">
          <div>
            <el-input v-model="formData.fileUrl" placeholder="请输入内容"></el-input>
            <el-upload
              class="upload-fujian"
              action="check/checkNew/uploadFilezhanNeiRYDLCK"
              :headers="headers"
              :with-credentials="true"
              :on-success="uploadSuccess"
            >
              <el-button size="mini" type="primary">上传</el-button>
            </el-upload>
          </div>
        </template> -->

        <template slot-scope="scope" slot="menuForm">
          <el-button type="primary" @click="handleSubmit(2)">保存</el-button>
          <el-button type="default" @click="closed">取消</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {
    fenExYuangettoFixed
  } from "../../../../../../api/subwayRat/commonCheck";
  import {updateSwAuConductorNotice} from "../../../../../../api/stationTiecketManager/xianWngCJXXQR/shouPiaoYuanPKCY/shouPiaoYuanPKCYQRTZ/zhanNeiRYDLCK";

  export default {
    components:{
    },
    data() {
      return {
        isReload:true,
        //1期限内，2期限外
        showType:1,
        dialogVisible:true,
        lineCodes:[],
        selectedKeys:[],
        stationCodes:[],
        conductorPersonNames:[],//售票员名称
        operationCodes:[],
        headers:{},
        formData:{
          dynamic: []
        },
        option:{
        },
        parentThis:null
    }
    },
    created() {
    },
    methods: {
      fenExYuangettoFixed,
      handleSubmit(auditSate){
        let th=this;
        let param={};
        param.fileUrl=this.formData.fileUrl;
        param.appealStatus=2;//已申诉
        param.auditSate=1;//待审批
        param.appealType=this.showType; //1期限内，2期限外
        //正常申诉必填
        if(this.showType == '1'){
          if(this.formData.appealReason == null || this.formData.appealReason == '' || this.formData.appealReason == undefined){
            this.$message.info('请输入申诉原因！')
            return false;
          }
          param.appealReason=this.formData.appealReason;
        }
        //超期申诉必填
        if(this.showType == '2'){
          if(this.formData.overtimeReason == null || this.formData.overtimeReason == '' || this.formData.overtimeReason == undefined){
            this.$message.info('请输入超期申诉原因！')
            return false;
          }
          param.overtimeReason=this.formData.overtimeReason;
        }
        param.remark=this.formData.remark;
        param.id=this.formData.id;
        updateSwAuConductorNotice(param).then(res=>{
            if(res.data.code==0){
              th.$message.success("操作成功！");
              th.closed();
              th.parentThis.getList();
            }else{
              th.$message.error("操作失败！");
            }
          }).catch((e)=>{
            th.$message.error("操作失败！");
          });
      },
      recallShow(row,showType,parentThis){
        this.parentThis=parentThis;
        this.showType=showType;
        this.getOption();
        this.formData=row;
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.dialogVisibleAppealReply=false;
      },
      getOption(){
        let th=this;
        this.option=this.getAddOption(th);
        this.isReload=false;
        this.$nextTick(()=>{
          this.isReload=true;
        })
      },
      uploadSuccess(response, file, fileList){
        this.formData.fileUrl=file.name;
        this.list=response.data;
        this.dialogVisible=true;
        this.getOption();
        console.log(response, file, fileList)
      },
      getAuth(){
        const token = this.$store.getters.access_token;
        if (token) {
          this.headers['Authorization'] = 'Bearer ' + token// token
        }
      },
      getAddOption(th) {
        return {
          submitBtn:false,
          emptyBtn:false,
          group:[
            {
              icon:'',
              label: '',
              // collapse:false,
              prop: 'group1',
              column: [{
                label: '售票员',
                prop: 'conductorPersonName',
                labelWidth:130,
                // formslot:true,
                type:'select'
              },{
                label: '售票员工号',
                prop: 'conductorPersonCode',
                labelWidth:130,
                // formslot:true,
                type:'select'
              },{
                label: '收入日期',
                prop: 'recordTime',
                // width:'250',
                labelWidth:130,
                type:"yyyy-MM-dd"
                // formslot:true,
              },{
                label: '申诉原因',
                prop: 'appealReason',
                // width:'250',
                labelWidth:130,
                type:'textarea',
                display:this.showType==1,
              },
              // {
              //   label: '附件',
              //   prop: 'fujian',
              //   labelWidth:130,
              //   formslot:true,
              // },
              {
                label: "上传附件",
                prop: "fileUrl",
                type: "upload",
                labelWidth:130,
                component: "zd-upload",
                dataType: "string",
                display:false
              },
              {
                label: '超期申诉原因',
                prop: 'overtimeReason',
                // width:'250',
                labelWidth:130,
                type:'textarea',
                display:this.showType==2,
                rules: [
                  { required: true, trigger: 'blur', message: '请输入超期申诉原因' },
                ]
              },{
                label: '备注',
                prop: 'remark',
                // width:'250',
                labelWidth:130,
                type:'textarea',
              }]
            },
          ]
        };
      }
    },
    mounted() {
      this.getAuth();
    }
  }
</script>
<style lang="scss">
  .huLianWangShouPiaojiDataInput.EditorOrAdd{
    .avue-group[index='2']{
      .avue-form__group{
        .avue-form__row{
          width: 100%;
        }
      }
    }
    @media only screen and (min-width: 992px){
      width: 100%;
    }
    .avue-crud__tip{
      display: none;
    }
  }
.zhanNeiRYDLCK {
  .upload-fujian{
    display: inline-flex;
    .el-upload-list {
      display: none;
    }
}

}
</style>
